#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <iostream>

using namespace std;


#define ITERATIONS 10
const int CELLS = 10;

int CheckCells(int left, int mid, int right)
{
	int result = left << 2 | mid << 1 | right;
	result = 1 << result;
	result = 184 & result;

	return static_cast<int>((result!=0));

}

void main(void)
{
	int cells[CELLS];
	int tmp[CELLS];
	int newState;

	for(int i=0; i < CELLS; i++)
	{
		cells[i] = rand() % 2;
		cout << cells[i] << " ";
	}

	cout << endl;
	//iterations
	for(int i = 0; i < ITERATIONS; i++)
	{
		//first cell
		tmp[0] = CheckCells(0, cells[0], cells[1]);

		//last cell
		tmp[CELLS-1] = CheckCells(cells[CELLS-2], cells[CELLS-1], 0);

		for(int j = 1; j < CELLS-1; j++)
		{
			tmp[j] = CheckCells(cells[j-1], cells[j], cells[j+1]);
		}

		for(int k = 0; k < CELLS; k++)
		{
			cout << tmp[k] << " ";
		}
		cout << endl;
		memcpy(cells,tmp,sizeof(int)*CELLS);
	}
	
	
}